package com.woniu.liuzhougov.fileManage.service.impl;

import com.woniu.liuzhougov.fileManage.dao.FileDataMapper;
import com.woniu.liuzhougov.fileManage.dao.ItemMapper;
import com.woniu.liuzhougov.fileManage.pojo.FileData;
import com.woniu.liuzhougov.fileManage.pojo.Item;
import com.woniu.liuzhougov.fileManage.service.FileService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @description: 业务逻辑
 * @author: Arvin
 * @create: 2019-04-19 17:17
 **/

@Service
public class FileServiceImpl implements FileService, ItemMapper {

    @Resource
    private FileDataMapper fileDataMapper;

    @Resource ItemMapper itemMapper;

    @Override
    public int uploadFile(FileData fileData) {
        return fileDataMapper.insertSelective(fileData);
    }

    @Override
    public List<FileData> findAllFileData() {
        return fileDataMapper.queryAllFileDataByPage();
    }

    @Override
    public boolean deleteFileById(int fileId) {
        fileDataMapper.deleteByPrimaryKey(fileId);
        return false;
    }

    @Override
    public List<FileData> searchListByFileName(String fileName) {
        return fileDataMapper.selFileByFileName(fileName);
    }

    @Override
    public FileData selUpdateForm(int fileId) {
        return fileDataMapper.selectByPrimaryKey(fileId);
    }

    @Override
    public FileData finFiledata(Integer fileId) {
        return fileDataMapper.selectByPrimaryKey(fileId);
    }

    @Override
    public List<Item> findAllSx() {
        return queryAllItems();
    }

    @Override
    public void updateFile(FileData fileData) {
        //fileDataMapper.updateByPrimaryKeySelective(fileData);
        fileDataMapper.updateOper(fileData);
    }

    @Override
    public FileData selectFileByName(String filenameUUID) {
        return fileDataMapper.selectFileByName(filenameUUID);
    }

    //查询所有事项
    @Override
    public List<Item> queryAllItems() {
        return itemMapper.queryAllItems();
    }
}
